﻿using TeamReview.UI;

namespace TeamReview.Command
{
    /// <summary>
    /// Shows <see cref="DirectionsForm"/>
    /// </summary>
    /// <remarks>
    /// Template Pattern implementor of <see cref="ShowFormCommand"/>
    /// </remarks>
    internal class ShowDirectionsFormCommand : ShowFormCommand
    {
        private DirectionsForm helpForm;

        /// <remarks>
        /// This implementation overrides the alogrithim of <see cref="ShowFormCommand"/> in order
        /// to avoid a recursive invocation chain
        /// </remarks>
        public override void Execute()
        {
            ShowForm();
        }

        /// <summary>
        /// Only included for completeness
        /// </summary>
        /// <returns></returns>
        protected override bool GetEnabledState()
        {
            return true;
        }

        /// <summary>
        /// Show <see cref="DirectionsForm"/>
        /// </summary>
        protected override void ShowForm()
        {
            if (helpForm == null)
                helpForm = new DirectionsForm();

            helpForm.ShowDialog();
        }

        public override void Shutdown()
        {
            if (helpForm != null)
            {
                helpForm.Close();
                helpForm.Dispose();
            }
        }
    }
}
